<?php echo $this->fetch('header.html'); ?>
<script type="text/javascript">
//<!CDATA[
$(function(){
    // multi-select mall_gcategory
    $('#gcategory').length>0 && gcategoryInit("gcategory");
    var if_show = '<?php echo $_GET['if_show']; ?>';
    $('.one').click(function () {
        var obj = $(this);
        //取得商品ID
        var goods_id = $(this).attr("goods_id");

        $.post("index.php?app=access&act=examine", {"goods_id": goods_id}, function(data){

            //返回1则全部审核通过
            if(1 == data){
                //删除一行
                var tr = obj.parent().parent("tr");
                //改变图片
                var img = tr.children().find("img.shangjia");
                img.attr("src",SITE_URL +"/admin/templates/style/images/positive_enabled.gif");
                //如果看的是下架商品，则状态更改为上架时移除商品
                if(0 == if_show){
                    tr.remove();
                }
            }else if(0 == data){
                var tr = obj.parent().parent("tr");

                //改变图片
                var img = tr.children().find("img.shangjia");
                img.attr("src",SITE_URL +"/admin/templates/style/images/positive_disabled.gif");
                //
                if(if_show == 1){
                    tr.remove();
                }
            }
            var num = $("table.dataTable tr").length;
            if(1 == num){
                location.reload();
            }
            if(1 == data || 0 == data){
                //改变界面的显示
                var s = obj.attr("s");
                if(1 == s) {
                    obj.html("未审核");
                    obj.attr("s","0");
                }else{
                    obj.html("已审核");
                    obj.attr("s","1");
                }
            }
        }, "json");

    })

    $('.two').click(function () {
        var obj = $(this);
        //取得商品ID
        var goods_id = $(this).attr("goods_id");

        $.post("index.php?app=access&act=finance", {"goods_id": goods_id}, function(data){
            //返回1则全部审核通过
            if(1 == data){
                //删除一行
                var tr = obj.parent().parent("tr");
//                tr.remove();
                //改变图片
                var img = tr.children().find("img.shangjia");
                img.attr("src",SITE_URL +"/admin/templates/style/images/positive_enabled.gif");
                //如果看的是下架商品，则状态更改为上架时移除商品
                if(0 == if_show){
                    tr.remove();
                }
            }else if(0 == data){
                var tr = obj.parent().parent("tr");
                //改变图片
                var img = tr.children().find("img.shangjia");
                img.attr("src",SITE_URL +"/admin/templates/style/images/positive_disabled.gif");
                //如果看的是下架商品，则状态更改为上架时移除商品
                if(1 == if_show){
                    tr.remove();
                }
            }

            var num = $("table.dataTable tr").length;
            if(1 == num){
                location.reload();
            }

            if(1 == data || 0 == data){
                //改变界面的显示
                var s = obj.attr("s");
                if(1 == s) {
                    obj.html("未审核");
                    obj.attr("s","0");
                }else{
                    obj.html("已审核");
                    obj.attr("s","1");
                }
            }
        }, "json");


    })
    $("select#cate2").change(function(){
        var v = $(this).val();
        if(v != 0){
            $("input[name='cate_id']").val(v);
        }else{
            var one = $("select.querySelect option:selected").val();;
            $("input[name='cate_id']").val(one);
        }
    })
});
//]]>
</script>
<div id="rightTop">
  <p>商品</p>
  <ul class="subnav">
    <li><?php if ($_GET['if_finance'] == 0 || $_GET['if_examine'] == 0 && isset ( $_GET['if_examine'] ) && isset ( $_GET['if_finance'] )): ?><a class="btn1" href="index.php?app=goods&amp;if_examine=1&amp;if_finance=1">已审核</a><?php else: ?><span>已审核</span><?php endif; ?></li>
    <li><?php if ($_GET['if_examine'] == 1 || ! isset ( $_GET['if_examine'] )): ?><a class="btn1" href="index.php?app=goods&amp;if_examine=0">商品审核</a><?php else: ?><span>商品审核</span><?php endif; ?></li>
    <li><?php if ($_GET['if_finance'] == 1 || ! isset ( $_GET['if_finance'] )): ?><a class="btn1" href="index.php?app=goods&amp;if_finance=0">财务审核</a><?php else: ?><span>财务审核</span><?php endif; ?></li>
  </ul>
</div>
<div class="mrightTop1 info">
  <div class="fontl">
    <form method="get">
      <input type="hidden" name="app" value="goods" />
      <?php if ($_GET['closed']): ?>
      <input type="hidden" name="closed" value="1" />
      <?php endif; ?> 商品名:
      <input class="queryInput" type="text" name="goods_name" value="<?php echo htmlspecialchars($_GET['goods_name']); ?>" />
      店铺名:
      <input class="queryInput" type="text" name="store_name" value="<?php echo htmlspecialchars($_GET['store_name']); ?>" />
      品牌:
      <input class="queryInput" type="text" name="brand" value="<?php echo htmlspecialchars($_GET['brand']); ?>" /><br />
      <span style="position: relative; top: 5px;">
      <div class="left">
          分类名:
          <div id="gcategory" style="display:inline;">
            <input type="hidden" name="cate_id" value="<?php echo $this->_var['ccate']; ?>" class="mls_id" />
            <select class="querySelect">
              <option>请选择...</option>
                <?php $_from = $this->_var['gcategories']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'cate');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['cate']):
?>
                <option value="<?php echo $this->_var['key']; ?>" <?php if ($this->_var['cate_id'] == $this->_var['key']): ?>selected ="selected"<?php endif; ?>><?php echo $this->_var['cate']; ?></option>
                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
            </select>
              <select id="cate2">
                  <option value="0">请选择...</option>
                  <?php $_from = $this->_var['cate1']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('k', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['k'] => $this->_var['c']):
?>
                  <option value="<?php echo $this->_var['c']['cate_id']; ?>" <?php if ($this->_var['cate_id1'] == $this->_var['c']['cate_id']): ?>selected ="selected"<?php endif; ?>><?php echo $this->_var['c']['cate_name']; ?></option>
                  <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
              </select>
          </div>
          <input type="submit" class="formbtn" value="查询" />
      </div>
      <?php if ($_GET['cate_id'] || $this->_var['query']['goods_name'] || $this->_var['query']['store_name'] || $this->_var['query']['brand']): ?>
      <a class="left formbtn1" href="index.php?app=goods<?php if ($this->_var['query']['closed']): ?>&amp;closed=<?php echo $this->_var['query']['closed']; ?><?php endif; ?>">撤销检索</a>
      <?php endif; ?>
      </span>
    </form>
  </div>
    
    <div class="fontl">&nbsp;</div>
    <div class="fontl">
        <form method="post">
            <input type="hidden" name="action" value="export" />
            <input type="submit" class="formbtn" value="导出" />
        </form>
    </div>
  <div class="fontr"><?php echo $this->fetch('page.top.html'); ?></div>
</div>
<div class="tdare">
  <table width="100%" cellspacing="0" class="dataTable">
    <?php if ($this->_var['goods_list']): ?>
    <tr class="tatr1">
      <td width="10%" class="firstCell"><input type="checkbox" class="checkall" /></td>
	  <?php if ($this->_var['enable_radar']): ?><td width="10%">商品雷达</td><?php endif; ?>
      <td width="15%"><span ectype="order_by" fieldname="goods_name">商品名</span></td>
      <td width="10%"><span ectype="order_by" fieldname="store_name">店铺名</span></td>
      <td><span ectype="order_by" fieldname="brand">品牌</span></td>
      <td width="10%><span ectype="order_by" fieldname="cate_id">分类名</span></td>
        <td><span ectype="order_by" fieldname="brand">价格</span></td>
        <td><span ectype="order_by" fieldname="brand">进货价</span></td>
        <td><span ectype="order_by" fieldname="brand">利润</span></td>
      <td class="table-center"><span ectype="order_by" fieldname="if_show">上架</span></td>
      <td class="table-center"><span ectype="order_by" fieldname="closed">禁售</span></td>
      <td><span ectype="order_by" fieldname="views">浏览数</span></td>
        <td><span ectype="order_by" fieldname="brand">商品审核</span></td>
        <td><span ectype="order_by" fieldname="brand">财务审核</span></td>
      <td>操作</td>
    </tr>
    <?php endif; ?>
    <?php $_from = $this->_var['goods_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'goods');if (count($_from)):
    foreach ($_from AS $this->_var['goods']):
?>
    <tr class="tatr2">
      <td class="firstCell"><input type="checkbox" class="checkitem" value="<?php echo $this->_var['goods']['goods_id']; ?>"/></td>
    <?php if ($this->_var['enable_radar']): ?>
    <td><span id="r<?php echo $this->_var['goods']['goods_id']; ?>"class="radar_product_point" radar_price="<?php echo $this->_var['goods']['shop_price']; ?>" radar_product_id='<?php echo $this->_var['goods']['goods_id']; ?>' radar_brand="<?php echo $this->_var['goods']['brand_name']; ?>"  radar_catname="<?php echo $this->_var['goods']['cat_name']; ?>" radar_sn="<?php echo $this->_var['goods']['goods_sn']; ?>" radar_keyword="" radar_name="<?php echo htmlspecialchars($this->_var['goods']['goods_name']); ?>"></span></td>
    <?php endif; ?>
      <td><span ectype="inline_edit" fieldname="goods_name" fieldid="<?php echo $this->_var['goods']['goods_id']; ?>" required="1" class="editable" title="可编辑"><?php echo htmlspecialchars($this->_var['goods']['goods_name']); ?></span></td>
      <td><?php echo htmlspecialchars($this->_var['goods']['store_name']); ?></td>
      <td><?php echo htmlspecialchars($this->_var['goods']['brand']); ?></td>
      <td><?php echo nl2br($this->_var['goods']['cate_name']); ?></td>
      <td><?php echo price_format($this->_var['goods']['price']); ?></td>
      <td><?php echo price_format($this->_var['goods']['supply_price']); ?></td>
      <td><?php echo price_format($this->_var['goods']['rate']); ?></td>
      <td class="table-center"><?php if ($this->_var['goods']['if_show']): ?><img class="shangjia" src="<?php echo $this->res_base . "/" . 'style/images/positive_enabled.gif'; ?>" /><?php else: ?><img class="shangjia" src="<?php echo $this->res_base . "/" . 'style/images/positive_disabled.gif'; ?>" /><?php endif; ?></td>
      <td class="table-center"><?php if ($this->_var['goods']['closed']): ?><img src="<?php echo $this->res_base . "/" . 'style/images/negative_enabled.gif'; ?>" ectype="inline_edit" fieldname="closed" fieldid="<?php echo $this->_var['goods']['goods_id']; ?>" fieldvalue="1" title="可编辑"/><?php else: ?><img src="<?php echo $this->res_base . "/" . 'style/images/negative_disabled.gif'; ?>" ectype="inline_edit" fieldname="closed" fieldid="<?php echo $this->_var['goods']['goods_id']; ?>" fieldvalue="0" title="可编辑"/><?php endif; ?></td>
      <td><?php echo ($this->_var['goods']['views'] == '') ? '0' : $this->_var['goods']['views']; ?></td>
        <td><a class="one" goods_id="<?php echo $this->_var['goods']['goods_id']; ?>" s = "<?php echo $this->_var['goods']['if_examine']; ?>" href="javascript:void(0)"><?php if ($this->_var['goods']['if_examine']): ?>已审核<?php else: ?>未审核<?php endif; ?></a></td>
        <td><a class="two" goods_id="<?php echo $this->_var['goods']['goods_id']; ?>" s = "<?php echo $this->_var['goods']['if_finance']; ?>" href="javascript:void(0)"><?php if ($this->_var['goods']['if_finance']): ?>已审核<?php else: ?>未审核<?php endif; ?></a></td>
      <td><a target="_blank" href="<?php echo $this->_var['site_url']; ?>/index.php?app=goods&amp;id=<?php echo $this->_var['goods']['goods_id']; ?>&amp;action=view">查看</a></td>
    </tr>
    <?php endforeach; else: ?>
    <tr class="no_data info">
      <td colspan="8">没有符合条件的记录</td>
    </tr>
    <?php endif; unset($_from); ?><?php $this->pop_vars();; ?>
  </table>
  <?php if ($this->_var['goods_list']): ?>
  <div id="dataFuncs">
    <div id="batchAction" class="left paddingT15"> <?php if (! $_GET['closed']): ?>
      <input class="formbtn batchButton" type="button" value="推荐" name="id" uri="index.php?app=goods&act=recommend&ret_page=<?php echo $this->_var['page_info']['curr_page']; ?>" />
          &nbsp;&nbsp;<?php endif; ?>
      <input class="formbtn batchButton" type="button" value="编辑" name="id" uri="index.php?app=goods&act=edit&ret_page=<?php echo $this->_var['page_info']['curr_page']; ?>" />&nbsp;&nbsp;
      <input class="formbtn batchButton" type="button" value="删除" name="id" uri="index.php?app=goods&act=drop&ret_page=<?php echo $this->_var['page_info']['curr_page']; ?>" presubmit="confirm('您确定要删除该商品吗（不可恢复）？')" />
    </div>
    <div class="pageLinks"><?php echo $this->fetch('page.bottom.html'); ?></div>
   <?php endif; ?>
  </div>
  <div class="clear"></div>
</div>
<?php echo $this->fetch('footer.html'); ?><?php if ($this->_var['enable_radar']): ?>
<input type="hidden" id="radar_lincense_id" value="" />
<input type="hidden" id="radar_product_key" value="ecmall" />
<input type="hidden" id="radar_sign_key" value="" />
<script type="text/javascript" src="http://js.sradar.cn/radarForGoodsList.js"></script>
<script>
radar_point_extract();
</script>
<?php endif; ?>